//
//  BluetoothManager.h
//  Pods
//
//  Created by jacky on 2021/8/10.
//
#import <CoreBluetooth/CoreBluetooth.h>

NS_ASSUME_NONNULL_BEGIN
@protocol BluetoothManagerDelegate <NSObject>

@optional
- (void)didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI;

- (void)didConnectPeripheral:(CBPeripheral *)peripheral;

- (void)didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;

- (void)didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error;

- (void)didDiscoverServices:(nullable NSError *)error;

- (void)didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error;

- (void)didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error;

- (void)didUpdateState:(NSInteger)state;

@end

@interface BluetoothManager : NSObject

@property (nonatomic, weak) id<BluetoothManagerDelegate> delegate;

+ (instancetype)sharedInstance;

- (void)startWithAutoConnect:(NSString *)name;

- (bool)start;

- (void)stop;

- (void)connectPeripheral:(NSString *)name;

- (void)restarScan;

- (NSInteger)getStatus;
 
@end

NS_ASSUME_NONNULL_END
